import { createRouter, createWebHashHistory } from "vue-router";
import NotFound from "../components/NotFound/index.vue";

const routes = [
  // {
  //   path: "/login",
  //   component: () => import("@/views/login/index.vue"),
  // },
  {
    path: "/home",
    component: () => import("@/views/home/index.vue"),
  },
  {
    path: "/blog",
    component: () => import("@/views/blog/index.vue"),
    children: [
      {
        path: "",
        component: () => import("@/views/blog/blogPage/index.vue"),
      },
      {
        path: "details/:Bid",
        component: () => import("@/views/blog/details/index.vue"),
      },
    ],
  },
  {
    path: "/editor",
    component: () => import("@/views/editor/index.vue"),
  },
  {
    path: "/user",
    component: () => import("@/views/user/index.vue"),
    children: [
      {
        path: "profile",
        component: () => import("@/views/user/profile/index.vue"),
      },
      {
        path: "account",
        component: () => import("@/views/user/account/index.vue"),
      },
      {
        path: "/user",
        redirect: "/user/profile",
      },
    ],
  },
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/:pathMatch(.*)*",
    component: NotFound,
  },
];
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
router.beforeEach(async (to, from, next) => {
  // if ()
  //   next({
  //     path: "",
  //   });
  // else
  //   next({
  //     path: "",
  //   });
  next();
});
router.afterEach((to, from, next) => {
  window.scrollTo(0, 0);
});
export default router;
